<?php
namespace app\admin\controller;

class MemberRealname extends Admin{
    public function __construct(){
        parent::__construct();
        $this->assign("model","MemberRealname");
    }
    public function update_status(){
    	$id = input("param.id");
    	$status = input("param.status");
        $info = model("MemberRealname")->get_data(['item_id'=>$id]);
        if ($status == 2) {
            $ids = model('MemberRealname')->where('id',$id)->delete();
            if (!$ids) {
                return json(['status'=>0,'msg'=>'操作失败']);
            }else{
                send_rongyun_sys_msg($info['userid'],'对不起，你的实名认证未通过审核，请重新提交。');
            }
        }
        if ($status == 1) {
            $age = getAgeByID($info['idcard']);
            $result = db("MemberRealname")->where('id', $id)->setField('status', $status);
            $ids = model('Member')->where('id',$info['userid'])->update(['realname' => $info['realname'],'realauth'=>1,'age'=>$age]);
            if (!$ids) {
                return json(['status'=>0,'msg'=>'操作失败']);
            }else{
                send_rongyun_sys_msg($info['userid'],'恭喜你，你的实名认证已通过！');
            }
        }
        return json(['status' => 1,'msg'=>'操作成功']);
	}
    public function images(){
        $id = input('param.id');
        $info = model('MemberRealname')->get_data(['item_id'=>$id]);
        trace($info);
        $this->assign('info', $info);
        return $this->fetch();
    }
}